﻿using Microsoft.AspNet.SignalR;
using Microsoft.AspNet.SignalR.Hubs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Server.Hubs
{
    [HubName("chatHub")]
    public class ChatHub : Hub
    {
        public void JoinRoom(string roomName,string userName)
        {
            Groups.Add(Context.ConnectionId, roomName);

            Clients.OthersInGroup(roomName).UserJoinedMessage(userName);
        }

        public void SendMessage(string roomName,string userName,string message)
        {
            Clients.OthersInGroup(roomName).ReceiveMessage(userName + ": " + message);
        }
    }
}